#!/usr/bin/env ruby
require 'rubygems'
require 'json'

out=Hash.new
key=''

ARGV.each do |arg|
  if arg =~ /^--/
    key=arg[2..-1]
  else
    unless key
      STDERR.puts "Aieee, arg without a key!"
      exit 1
    end
    arg=File.read(arg[1..-1]) if arg =~ /^@/ and File.exists?(arg[1..-1])
    if out[key]
      out[key]="#{out[key]}\n\n#{arg}"
    else
      out[key]="#{arg}"
    end
  end
end
puts JSON.pretty_generate out
